package edu.hawaii.solardecathlon.page.settings;

import java.util.Arrays;
import java.util.List;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import edu.hawaii.solardecathlon.page.BasePanel;

/**
 * The User Privileges Page.
 * 
 * @author Michael Cera
 */
public class SettingsUserPrivilegesPanel extends BasePanel {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  /**
   * List of groups.
   */
  private static final List<String> groups = Arrays.asList(new String[] { "Adminstrator", "User",
      "Guest" });

  /**
   * Creates the User Privileges Page.
   * 
   * @param id String
   */
  public SettingsUserPrivilegesPanel(String id) {
    super(id);

    // Create the form that shows settings
    Form<String> form = new Form<String>("UserPrivilegesForm");

    // Create groups dropdown box.
    form.add(new DropDownChoice<String>("GroupDropDown", groups));

    // Save button, currently does not process the form.
    Button addGroup = new Button("add_group") {
      private static final long serialVersionUID = 1L;

      /** Refresh the page. */
      @Override
      public void onSubmit() {
        setResponsePage(SettingsPage.class);
      }
    };
    // Disable processing of form.
    addGroup.setDefaultFormProcessing(false);
    form.add(addGroup);

    // Save button, currently does not process the form.
    Button addUser = new Button("add_user") {
      private static final long serialVersionUID = 1L;

      /** Refresh the page. */
      @Override
      public void onSubmit() {
        setResponsePage(SettingsPage.class);
      }
    };
    // Disable processing of form.
    addUser.setDefaultFormProcessing(false);
    form.add(addUser);

    // Add the form to this page.
    add(form);
  }
}
